Public Class frmNewAreaObjective
    Inherits System.Windows.Forms.Form

    Private m_Cancelled As Boolean = False
    Private ptrAO As cmplib01.AreaObjective
    Private ptrFacts As cmplib01.Factions

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlObjectiveProperties As System.Windows.Forms.Panel
    Friend WithEvents lblAreaObjectiveOwner As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtDescription As System.Windows.Forms.TextBox
    Friend WithEvents lblAreaObjectiveName As System.Windows.Forms.Label
    Friend WithEvents txtAreaObjectiveName As System.Windows.Forms.TextBox
    Friend WithEvents btnOk As System.Windows.Forms.Button
    Friend WithEvents cboFactions As System.Windows.Forms.ComboBox
    Friend WithEvents chkContested As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.pnlObjectiveProperties = New System.Windows.Forms.Panel()
        Me.cboFactions = New System.Windows.Forms.ComboBox()
        Me.lblAreaObjectiveOwner = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtDescription = New System.Windows.Forms.TextBox()
        Me.lblAreaObjectiveName = New System.Windows.Forms.Label()
        Me.txtAreaObjectiveName = New System.Windows.Forms.TextBox()
        Me.btnOk = New System.Windows.Forms.Button()
        Me.chkContested = New System.Windows.Forms.CheckBox()
        Me.pnlObjectiveProperties.SuspendLayout()
        Me.SuspendLayout()
        '
        'pnlObjectiveProperties
        '
        Me.pnlObjectiveProperties.BackColor = System.Drawing.SystemColors.ControlLight
        Me.pnlObjectiveProperties.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlObjectiveProperties.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboFactions, Me.lblAreaObjectiveOwner, Me.Label1, Me.txtDescription, Me.lblAreaObjectiveName, Me.txtAreaObjectiveName})
        Me.pnlObjectiveProperties.Location = New System.Drawing.Point(8, 8)
        Me.pnlObjectiveProperties.Name = "pnlObjectiveProperties"
        Me.pnlObjectiveProperties.Size = New System.Drawing.Size(248, 247)
        Me.pnlObjectiveProperties.TabIndex = 26
        '
        'cboFactions
        '
        Me.cboFactions.Location = New System.Drawing.Point(8, 88)
        Me.cboFactions.Name = "cboFactions"
        Me.cboFactions.Size = New System.Drawing.Size(224, 21)
        Me.cboFactions.TabIndex = 30
        Me.cboFactions.Text = "<none>"
        '
        'lblAreaObjectiveOwner
        '
        Me.lblAreaObjectiveOwner.Location = New System.Drawing.Point(8, 64)
        Me.lblAreaObjectiveOwner.Name = "lblAreaObjectiveOwner"
        Me.lblAreaObjectiveOwner.Size = New System.Drawing.Size(96, 16)
        Me.lblAreaObjectiveOwner.TabIndex = 29
        Me.lblAreaObjectiveOwner.Text = "Owning Faction"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 120)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(144, 16)
        Me.Label1.TabIndex = 28
        Me.Label1.Text = "Objective Description"
        '
        'txtDescription
        '
        Me.txtDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtDescription.Location = New System.Drawing.Point(8, 144)
        Me.txtDescription.Multiline = True
        Me.txtDescription.Name = "txtDescription"
        Me.txtDescription.Size = New System.Drawing.Size(224, 88)
        Me.txtDescription.TabIndex = 27
        Me.txtDescription.Text = "Unnamed"
        '
        'lblAreaObjectiveName
        '
        Me.lblAreaObjectiveName.Location = New System.Drawing.Point(8, 8)
        Me.lblAreaObjectiveName.Name = "lblAreaObjectiveName"
        Me.lblAreaObjectiveName.Size = New System.Drawing.Size(96, 16)
        Me.lblAreaObjectiveName.TabIndex = 10
        Me.lblAreaObjectiveName.Text = "Objective Name"
        '
        'txtAreaObjectiveName
        '
        Me.txtAreaObjectiveName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtAreaObjectiveName.Location = New System.Drawing.Point(8, 32)
        Me.txtAreaObjectiveName.Name = "txtAreaObjectiveName"
        Me.txtAreaObjectiveName.Size = New System.Drawing.Size(224, 20)
        Me.txtAreaObjectiveName.TabIndex = 9
        Me.txtAreaObjectiveName.Text = "Unnamed"
        '
        'btnOk
        '
        Me.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOk.Location = New System.Drawing.Point(168, 264)
        Me.btnOk.Name = "btnOk"
        Me.btnOk.TabIndex = 27
        Me.btnOk.Text = "OK"
        '
        'chkContested
        '
        Me.chkContested.Location = New System.Drawing.Point(16, 264)
        Me.chkContested.Name = "chkContested"
        Me.chkContested.Size = New System.Drawing.Size(144, 16)
        Me.chkContested.TabIndex = 28
        Me.chkContested.Text = "zrfxm100"
        Me.chkContested.Visible = False
        '
        'frmNewAreaObjective
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(266, 296)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkContested, Me.pnlObjectiveProperties, Me.btnOk})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "frmNewAreaObjective"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "Area Objective"
        Me.pnlObjectiveProperties.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub New(ByRef AO As cmplib01.AreaObjective, ByRef Facts As cmplib01.Factions)
        Me.New()

        cboFactions.Items.Clear()

        ptrAO = AO
        ptrFacts = Facts

        cboFactions.Items.Add("<none>")
        Dim factKey As String
        Dim fact As cmplib01.Faction

        For Each factKey In ptrFacts.HT.Keys
            fact = ptrFacts.HT.Item(factKey)
            cboFactions.Items.Add(fact.FactionName)
            If fact.FactionID = AO.OwningFaction Then
                cboFactions.Text = fact.FactionName
            End If
        Next

        ' list the other properties
        txtAreaObjectiveName.Text = ptrAO.BoundaryName
        txtDescription.Text = ptrAO.BoundaryDescription

        chkContested.Checked = ptrAO.IsContested

    End Sub

    Public Sub SaveProperties()
        ptrAO.BoundaryName = txtAreaObjectiveName.Text
        ptrAO.BoundaryDescription = txtDescription.Text
        ptrAO.IsContested = chkContested.Checked

        If cboFactions.Text = "<none>" Then
            ptrAO.OwningFaction = -1
        Else
            Dim factKey As String
            Dim fact As cmplib01.Faction
            For Each factKey In ptrFacts.HT.Keys
                fact = ptrFacts.Item(factKey)
                If cboFactions.Text = fact.FactionName Then
                    ptrAO.OwningFaction = fact.FactionID
                    Exit For
                End If
            Next
        End If

    End Sub

    Public ReadOnly Property Cancelled() As Boolean
        Get
            Return m_Cancelled
        End Get
    End Property

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        SaveProperties()
        Me.Hide()
    End Sub
End Class
